package tech.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.pojo.Product;
import tech.aistar.pojo.User;

import java.util.List;

public interface ProductMapper {
    @Select("select * from product")
    List<Product> findAll();

    @Select("select * from product where name=#{value}")
    Product getByName(String name);

    @Select("select * from product where name=#{uname} and price=#{price}")
    Product getByUsernameAndPrice(@Param("uname") String username, @Param("price") int  price);

    //返回类型int - 受影响行数.如果插入一条成功,返回1
    //如果插入失败,返回数字0
    //反射技术
    //规则:只要占位符的名称和参数对象类型的属性的名称高度保持一致即可
    @Insert("insert into product(price,name,img_url,description) values(#{price},#{name},#{imgUrl},#{description})")
    int Addsave(Product product);



}
